package com.yanqu.road.dataHelper.action;

import com.yanqu.road.dataHelper.action.excel.ExpireDataLimitDelete;
import com.yanqu.road.dataHelper.gameServer.GameServer;
import com.yanqu.road.dataHelper.manager.ServerMgr;
import com.yanqu.road.entity.servercenter.ServerInfo;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

public class ExpireDataLimitDeleteAction extends actionBase{
    public void go(List<Long> serverList){
        ExecutorService executorService = Executors.newFixedThreadPool(10);
        List<Future> futureList = new ArrayList<>();
        for(Long serverId : serverList){
            if(ServerMgr.getServerInfoList().containsKey(serverId)){
                ServerInfo serverInfo = ServerMgr.getServerInfoList().get(serverId);
                Future future = executorService.submit(() -> {
                    GameServer testGameServer = new GameServer(serverInfo);
                    ExpireDataLimitDelete aaa = new ExpireDataLimitDelete(testGameServer);
                    aaa.go();
                    return true;
                });
                futureList.add(future);
            }
        }
        isResult(futureList);
    }
}
